Skip to content

Add Databricks agent invocation operator and hook - #74386

Open
AlejandroMorgante wants to merge 10 commits into
apache:mainfrom
AlejandroMorgante:add-databricks-agent-invoke
Open

AlejandroMorgante wants to merge 10 commits into
apache:mainfrom
AlejandroMorgante:add-databricks-agent-invoke

Conversation

@AlejandroMorgante

@AlejandroMorgante AlejandroMorgante commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Add DatabricksAgentInvokeOperator and DatabricksAgentHook to invoke agents hosted with DurableAgentServer on Databricks Apps. Supports service principal OAuth, background submission, synchronous polling and deferrable waiting, preserving the full invocation response in XCom.

The hook implements BaseManagedAgentHook for Common AI and toolset use, with a default session per invocation. Request, state and error handling were checked against the runtime and templates in Databricks' databricks-ai-bridge repository, tag databricks-agentbricks-v0.4.0. Stored failures are distinguished from transient HTTP errors, and interruptions nested in the output are returned by the operator and rejected by Common AI.

Invocation IDs remain stable across retries and clears with unchanged input and session. Stored failures stop task retries and require a new ID to run again. Polling requests and retries respect the remaining timeout budget.

Includes documentation, focused unit tests and a deterministic system-test fixture requiring no model endpoint.

Validation of the latest changes:

  • 142 hook, operator and trigger tests passed in Breeze, also with the minimum tenacity==8.3.0.
  • 5 additional local checks passed against the real Databricks 0.4.0 runtime with simulated OAuth.
  • Targeted mypy, applicable static/manual checks, documentation build and spellcheck passed. The dependency lower-bound checker ran successfully in Breeze because its local prek environment lacks tomllib.

Earlier validation: the full Databricks suite passed (1087 passed, 12 skipped), and the system test passed against a real workspace with OAuth, including deferral and resumption. Those broader runs have not been repeated after the latest changes.

See the fixture README for deployment, configuration and cleanup. The fixture uses an in-memory store and does not test recovery across app restarts. With the app and configuration prepared:

SYSTEM_TESTS_ENV_ID=your-unique-id \
BREEZE_INIT_COMMAND='set -a; . /files/databricks-agent-system-test.env; set +a' \
breeze testing system-tests \
  --backend sqlite \
  --forward-credentials \
  --test-timeout 2400 \
  providers/databricks/tests/system/databricks/example_databricks_agent.py \
  -q

Was generative AI tooling used to co-author this PR?
  • Yes — Codex (GPT-6)

Generated-by: Codex (GPT-6) following the guidelines

@AlejandroMorgante

Copy link
Copy Markdown
Contributor Author

@SameerMesiah97 could you please help me with a review when you have some time? Thanks! 🙏

@AlejandroMorgante
AlejandroMorgante marked this pull request as draft October 9, 2026 19:31
@AlejandroMorgante
AlejandroMorgante marked this pull request as ready for review October 9, 2026 19:31
Comment thread providers/databricks/src/airflow/providers/databricks/hooks/agent.py Outdated
Comment thread providers/databricks/docs/operators/agent.rst
@AlejandroMorgante
AlejandroMorgante force-pushed the add-databricks-agent-invoke branch from 152283d to e13d7dd Compare October 9, 2026 23:25
Comment thread providers/databricks/src/airflow/providers/databricks/operators/agent.py Outdated
Comment thread providers/databricks/src/airflow/providers/databricks/hooks/agent.py Outdated
Comment thread providers/databricks/docs/operators/agent.rst Outdated
Comment thread providers/databricks/src/airflow/providers/databricks/hooks/agent.py Outdated
Comment thread providers/databricks/src/airflow/providers/databricks/operators/agent.py Outdated
Comment thread providers/databricks/tests/unit/databricks/operators/test_agent.py
Comment thread providers/databricks/tests/unit/databricks/hooks/test_agent.py Outdated
Comment thread providers/databricks/tests/system/databricks/example_databricks_agent.py Outdated
@AlejandroMorgante
AlejandroMorgante marked this pull request as draft October 10, 2026 15:25
Allow Airflow tasks to invoke DurableAgentServer agents deployed on Databricks Apps and wait without occupying a worker.

Generated-by: Codex (GPT-6)
Keep the new operator documentation valid for Sphinx and recognize the official MLflow spelling.

Generated-by: Codex (GPT-6)
Keep the operator guide focused on user configuration and invocation, following the existing Databricks documentation conventions.

Generated-by: Codex (GPT-6)
A completed response must not turn an expired invocation wait into success. Recoverable async disconnects should not fail a task immediately, and polling failures need safe context for diagnosis.

Generated-by: Codex (GPT-6)
Common AI consumers need to consult Databricks agents through the same contract as Vertex AI and Bedrock. Existing background and deferrable workflows must remain usable without installing the optional Common AI provider.

Generated-by: Codex (GPT-6)
Replacement mocks should follow Airflow's testing conventions so they remain tied to the API they represent.

Generated-by: Codex (GPT-6)
Mocked responses must reflect the Databricks runtime contract so session,
interruption, failure and idempotency defects cannot hide behind passing
tests. Non-default settings and unconditional assertions make routing and
polling regressions observable.

This draft PR step intentionally exposes failures pending implementation
fixes in the following commits.

Generated-by: Codex (GPT-6)
@AlejandroMorgante
AlejandroMorgante force-pushed the add-databricks-agent-invoke branch from 7266b14 to 7f3b704 Compare October 10, 2026 15:28
Stored failures and template interruptions must not be treated as
transient errors or completed answers. Task retries need to respect
the server's idempotency rules, and toolset calls need a session.

Generated-by: Codex (GPT-6)
Conditional expectations made individual regression cases harder to assess during review.

Generated-by: Codex (GPT-6)
Make agent task progress traceable from submission through completion without exposing request or response contents.

Generated-by: Codex (GPT-6)
@AlejandroMorgante

Copy link
Copy Markdown
Contributor Author

End-to-end validation

Validated commit 68fc3d9b60d8c6f24ef4e074d6bf052d09fd5ff2 against a real Databricks App running the deterministic agent fixture.

Both synchronous and deferrable invocations completed successfully. Verification tasks confirmed the response content, original input, and session ID. The deferrable task resumed successfully after the trigger fired.

Environment: Airflow 3.3.0, Python 3.12, PostgreSQL, and LocalExecutor. The test loaded the provider source from the PR commit. No model endpoint was used.

Successful Airflow run

Synchronous and deferrable tasks and their result checks succeeded

Synchronous invocation

Synchronous invocation submission, polling, and completion

Deferrable invocation

Deferral, successful trigger event, and invocation completion

Agent input and output

Original input and validated agent response

Databricks App

Deterministic agent running in Databricks

Databricks invocation logs

Accepted POST requests and successful GET requests for both invocations

The temporary OAuth secret was revoked and the Databricks App stopped after validation.

@AlejandroMorgante
AlejandroMorgante marked this pull request as ready for review October 11, 2026 01:05

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants